<template>
	<view class="page-wrapper">
		
		<view class="page-body">
			<view scroll-x class="table-wrap">
				<zb-table :show-header="true" :columns="detailColumn"  :border="true" :data="detailData">
				</zb-table>
			</view>
			<view class="c-line">
				<button type="primary" @tap="handleSubmit" style="background-color: rgb(46, 152, 177);">出 库</button>
			</view>
		</view>
		
	</view>
</template>

<script>
	import {
	  outStock,
	  agvTaskDispatch
	} from "./api"
	import {
		validateTrayCode,
		validateShelvesCode
	} from "@/utils/common"
	import { defaultPageConfig} from "@/const/index"
	export default {
		data() {
			return {
				detailColumn: [
					{ type:'index', label: '序号', align: 'center', width:54 },
					{
						name: 'startPosition',
						label: '起点地标',
						fixed: false,
						emptyString: '--',
						width:100
					},
					{
						name: 'endPosition',
						label: '目的地地标',
						fixed: true,
						sorter: false,
						width:100
					},
					{
						name: 'taskStatus',
						label: '任务状态'
					},
				],
				detailData:[]
				
			};
		},
		mounted() {
			this.getDetailData()
		},
		methods:{
			getDetailData(){
				agvTaskDispatch({
					...defaultPageConfig,
					searchFinish:"N",
					taskType:"OUT_EMPTY_TRAYS"
				}).then( res=>{
					if(res.code == 200){
						this.detailData = res.rows
					}
				})
			},
			async handleSubmit() {
				try {
					const confirmed = await this.$modal.confirm('确认提交？')
					if (!confirmed) return
					
					this.$modal.closeLoading()
					const res = await outStock({
						productNo:"KWL"
					})
					
					this.$modal.confirmClose(res.msg)
				} catch (error) {
					console.error('操作失败:', error)
					this.$modal.msg('操作失败，请重试')
				}
			}
		}
	}
</script>

<style lang="scss">
	.c-line{
		padding: 50rpx;
	}

</style>
